//
//  SAStatisticsTopUpCell.m
//  saasRetail
//
//  Created by 黄志刚 on 2021/7/22.
//

#import "SAStatisticsTopUpCell.h"
#import "SAStatisticsTopUpModel.h"

@interface SAStatisticsTopUpCell ()

@property (nonatomic, strong) UILabel *payTypeLab;
@property (nonatomic, strong) UILabel *payType2Lab;

@end

@implementation SAStatisticsTopUpCell

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    if(self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]){
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        [self initUI];
    }
    return self;
}

-(void)refreshWithModel:(SAStatisticsTopUpModel *)model andIndex:(NSInteger)index {
    SATopUpDetailModel *detailModel = nil;
    SATopUpDetailModel *detailModel2 = nil;
    if (index == 0) {
        detailModel = model.empRechargeDetail[0];
        if (model.empRechargeDetail.count > 1) {
            detailModel2 = model.empRechargeDetail[1];
        }
    }else if (index == 1) {
        detailModel = model.empRechargeDetail[2];
        if (model.empRechargeDetail.count > 3) {
            detailModel2 = model.empRechargeDetail[3];
        }
    }else {
        detailModel = model.empRechargeDetail[4];
    }
    
    NSString *amount = [NSString stringWithFormat:@"%0.2lf",[detailModel.amount doubleValue]/100.f].getEffectivePointString;
    self.payTypeLab.text = [NSString stringWithFormat:@"%@:%@",detailModel.rechargeType, amount];
    
    if (detailModel2 != nil) {
        NSString *amount2 = [NSString stringWithFormat:@"%0.2lf",[detailModel2.amount doubleValue]/100.f].getEffectivePointString;
        self.payType2Lab.text = [NSString stringWithFormat:@"%@:%@",detailModel2.rechargeType, amount2];
    }
}

-(void)initUI {
    [self.contentView addSubview:self.payTypeLab];
    [self.contentView addSubview:self.payType2Lab];
}

-(UILabel *)payTypeLab {
    if (!_payTypeLab) {
        _payTypeLab = [[UILabel alloc] initWithFrame:SARectMake(25, 0, 150, 35)];
        _payTypeLab.textColor = kBlackColor;
        _payTypeLab.textAlignment = NSTextAlignmentCenter;
        _payTypeLab.font = kFont(15);
    }
    return _payTypeLab;
}

-(UILabel *)payType2Lab {
    if (!_payType2Lab) {
        _payType2Lab = [[UILabel alloc] initWithFrame:SARectMake(200, 0, 150, 35)];
        _payType2Lab.textColor = kBlackColor;
        _payType2Lab.textAlignment = NSTextAlignmentCenter;
        _payType2Lab.font = kFont(15);
    }
    return _payType2Lab;
}

@end
